// import { getAllRoleList, isAccountExist } from '@/api/demo/system';
import { BasicColumn, FormSchema } from '@/components/Table';
import { Tinymce } from '@/components/Tinymce';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';
import { useI18n } from '@/hooks/web/useI18n';

const { t } = useI18n();
/**
 * transform mock data
 * {
 *  0: '华东分部',
 * '0-0': '华东分部-研发部'
 * '0-1': '华东分部-市场部',
 *  ...
 * }
 */
// export const deptMap = (() => {
//   const pDept = ['华东分部', '华南分部', '西北分部'];
//   const cDept = ['研发部', '市场部', '商务部', '财务部'];

//   return pDept.reduce((map, p, pIdx) => {
//     map[pIdx] = p;

//     cDept.forEach((c, cIndex) => (map[`${pIdx}-${cIndex}`] = `${p}-${c}`));

//     return map;
//   }, {});
// })();
//表头数据
export const columns: BasicColumn[] = [
  {
    title: 'id',
    dataIndex: 'id',
    width: 120,
  },
  {
    title: t('sys.configuration.name'),
    dataIndex: 'name',
    width: 120,
  },
  {
    title: t('sys.device.columns.type'),
    dataIndex: 'type',
    width: 120,
    customRender: ({ record }) => {
      const status = record.type;
      const color = status == 1 ? 'green' : status == 2 ? 'blue' : status == 3 ? 'orgin' : 'red';
      const text = status == 1 ?  t('sys.configuration.backstageService') : status == 2 ? 'MQ' : status == 3 ? 'Redis' : 'Zookeeper';
      return h(Tag, { color: color }, () => text);
    },
  },
  {
    title: t('sys.configuration.value'),
    dataIndex: 'val',
    width: 180,
    customRender: ({ record, text }) => {
      const color = 'blue';
      return h(Tag, { color: color }, () => text);
    },
  },
  {
    title: t('sys.configuration.describe'),
    dataIndex: 'remark',
    width: 180,
  },
];
//表头搜素数据
export const searchFormSchema: FormSchema[] = [
  {
    field: 'id',
    label: t('sys.informaionMatchaing.columns.videoTag'),
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'nickname',
    label: t('sys.log.name'),
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'type',
    label: '点赞范围',
    component: 'Select',
    colProps: { span: 4 },
  },
  {
    field: 'type',
    label: '评论范围',
    component: 'Select',
    colProps: { span: 4 },
  },
  {
    field: 'type',
    label: '模糊词搜索',
    component: 'Select',
    colProps: { span: 4 },
  },
];

export const accountFormSchema: FormSchema[] = [
  {
    field: 'name',
    component: 'Input',
    label: '名字',
    colProps: {
      span: 24,
    },
    rules: [{ required: true }],
  },
  {
    field: '配置',
    component: 'Select',
    label: '服务',
    colProps: {
      span: 24,
    },
    componentProps: {
      options: [
        {
          label: '后台服务',
          value: '1',
        },
        {
          label: 'MQ',
          value: '2',
        },
        {
          label: 'Redis',
          value: '3',
        },
        {
          label: 'Zookeeper',
          value: '4',
        },
      ],
    },
    rules: [{ required: true }],
  },
  {
    field: 'type',
    component: 'Input',
    label: t('sys.device.columns.type'),
    defaultValue: '',
    colProps: {
      span: 24,
    },
    rules: [{ required: true }],
  },
  {
    field: 'val',
    component: 'Input',
    label: '值',
    defaultValue: '',
    colProps: {
      span: 24,
    },
    rules: [{ required: true }],
  },
  {
    field: 'remark',
    component: 'Input',
    label: t('sys.configuration.describe'),
    defaultValue: '',
    colProps: {
      span: 24,
    },
  },
];

//基础字段
export const accountFormSchemaFields: FormSchema[] = [
  {
    field: 'title',
    component: 'Input',
    label: t('sys.video.columns.submitTitel'),
    defaultValue: '',

    rules: [{ required: true }],
  },
  {
    field: 'title',
    component: 'RadioGroup',
    label: t('sys.video.columns.isPhoto'),
    defaultValue: '',
    componentProps: {
      options: [
        {
          label: t('sys.configuration.YES'),
          value: '1',
        },
        {
          label: t('sys.configuration.NO'),
          value: '2',
        },
      ],
    },

    rules: [{ required: true }],
  },
  {
    field: 'title',
    component: 'RadioGroup',
    label: t('sys.video.columns.submitType'),
    defaultValue: '',
    rules: [{ required: true }],
    componentProps: {
      options: [
        {
          label: t('sys.video.columns.trueType'),
          value: '1',
        },
        {
          label: t('sys.video.columns.selectType'),
          value: '2',
        },
        {
          label: t('sys.video.columns.selectListType'),
          value: '3',
        },
      ],
    },
  },
  {
    field: 'title',
    component: 'Input',
    label: t('sys.video.columns.configurationOptions'),
    defaultValue: '',

    rules: [{ required: true }],
  },
];
